<template>
  <div class="message-list-cont">
      <div class="mess-wrapper" v-for="(item, index) in messageEduListSli" :key="index">
          <div class="mess-left">
              <div :class="item.isread == 0 ? 'bg blue':'bg grey'">

              </div>
              <div class="info">
                  <!-- 请前往<span class="choose" @click="goToDetail(item,index)">{{'工作池'}}</span> -->
                  <div>{{item.theme}}<Button type="primary" size="small" v-if="item.traintype=='考核未结束'" class="ml10">考核未结束</Button><Button type="warning" size="small" v-else class="ml10">{{item.traintype}}</Button></div>
                  <div class="grey-font"><Icon class="mr10" type="md-calendar" />{{item.maketime}}</div>
                  <div class="grey-font"><Icon class="mr10" type="ios-paper" />{{item.filename}}</div>
                  <div class="grey-font" v-if="item.time"><Icon class="mr10" type="ios-time" />{{item.startdate}} - {{item.enddate}}</div>

              </div>
          </div>
          <div class="mess-right"><Button type="primary" @click="goToDetail(item,index)">确定</Button></div>
      </div>
      <div class="message-page">
        <Page v-show="messageEduList.length > 0" @on-change="changePage" :current="currentPage" :total="total" :page-size="pageSize" />
      </div>
      <div class="tc" v-show="messageEduList.length == 0">暂无通知</div>

  </div>
</template>
<script>
export default {
  name: 'messEdu',
  props: ["messageEduList","currentPart"],
  data() {
    return {
        currentPage:1,
        pageSize:10,
        total:1,
        messageEduListSli:[],
        // current: "messageSys",
        // messageSys: 1,
        // messageMeet: 0,
        // messageEdu: 5,
        // messageCheck: 0,
        // messageEval: 0,
        // messageKnow: 0,
    };
  },
  computed: {
    // currentPart(){
    //     console.log(this.currentPart)
    //     if(this.currentPart == "messageEdu"){
    //         this.messageEduListSli = this.messageEduList.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize)
    //     }
    // }
  },
  watch:{
      messageEduList(){
        this.total = this.messageEduList ? this.messageEduList.length : 0
        this.messageEduListSli = this.messageEduList.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize)
    
      }
  },
  methods: {
      goToDetail(item,index){
        let obj={
          type:3,
          idList: item.trainid
        }
        this.api.updateWorkDiaryReadNotice(obj).then(res => {
          console.log(res)
          
          this.$store.commit('messageHasChangedFreshedQuickly', 'edu'+item.trainid);

          //先置为已读，再跳转
          this.$router.push({
              name:'examResultDetail',
              query: {
                item:{
                    trainid: item.trainid,
                    filepath: "",
                    trainflag: 1
                },
              }
          })
        })

    //   },
          //先置为已读，再跳转
        // this.$router.push({
        //     name:'examResultDetail',
        //     query: {
        //         item:{
        //             trainid: '1296038977522970625',
        //             filepath: "",
        //             trainflag: 1
        //         },
        //         Object:1
        //     }

        // })
      },
      changePage(num){
        this.currentPage = num
        this.messageEduListSli = this.messageEduList.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize)

      },

  },
  mounted() {
      console.log("edu")

      console.log("0",this.messageEduList)
      this.currentPage = 1
      this.total = this.messageEduList ? this.messageEduList.length : 0
      this.messageEduListSli = this.messageEduList.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize)

  }
};
</script>
<style lang="less">
@import "../index.less";
</style>